package aiku.numericalcontroloa.Controller.FinanceManagement;

import aiku.numericalcontroloa.Base.Utils.Result;
import aiku.numericalcontroloa.Model.Dto.DevicesDto;
import aiku.numericalcontroloa.Model.Dto.OrderManagement.OrderBillingDto;
import aiku.numericalcontroloa.Model.Dto.PaymentBillingDto;
import aiku.numericalcontroloa.Model.Entity.PaymentBilling;
import aiku.numericalcontroloa.Service.FinanceManagement.FinanceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 财务控制层
 * @Author 黄广庭
 * @Date 2024/6/10 21:03
 */
@RestController
@RequestMapping("/finance")
@Slf4j
public class FinanceController {

    private final FinanceService financeService;

    public FinanceController(FinanceService financeService) {
        this.financeService = financeService;
    }

    /**
     * 获取订单账单列表
     * @param orderBillingDto
     * @return
     */
    @PostMapping("/getBillingList")
    public Result getBillingList(@RequestBody OrderBillingDto orderBillingDto){
        return financeService.getBillingList(orderBillingDto);
    }

    /**
     * 获取已支付的支出账单
     * @param paymentBillingDto
     * @return
     */
    @PostMapping("/getPaymentBillingList")
    public Result getPaymentBillingList(@RequestBody PaymentBillingDto paymentBillingDto){
        return financeService.getPaymentBillingList(paymentBillingDto);
    }

    /**
     * 获取供应商账单
     * @param paymentBillingDto
     * @return
     */
    @PostMapping("/getSupplierBilling")
    public Result getSupplierBilling(@RequestBody PaymentBillingDto paymentBillingDto){
        return financeService.getSupplierBilling(paymentBillingDto);
    }

    /**
     * 供应商月结账单付款
     * @param paymentBillingDto
     * @return
     */
    @PostMapping("/paymentSupplierBilling")
    public Result paymentSupplierBilling(@RequestBody PaymentBillingDto paymentBillingDto){
        return financeService.paymentBillingDto(paymentBillingDto);
    }

    /**
     * 获取报销账单
     * @param paymentBillingDto
     * @return
     */
    @PostMapping("/getExpenseBilling")
    public Result getExpenseBilling(@RequestBody PaymentBillingDto paymentBillingDto){
        return financeService.getExpenseBilling(paymentBillingDto);
    }

    /**
     * 报销单付款
     * @param paymentBillingDto
     * @return
     */
    @PostMapping("/paymentExpenseBilling")
    public Result paymentExpenseBilling(@RequestBody PaymentBillingDto paymentBillingDto){
        return financeService.paymentExpenseBilling(paymentBillingDto);
    }

    /**
     * 计算利润
     * @param devicesDto
     * @return
     */
    @PostMapping("/calculatingProfit")
    public Result calculatingProfit(@RequestBody DevicesDto devicesDto){
        return financeService.calculatingProfit(devicesDto);
    }
}
